package com.gujiangbo.chapter15;

/**
 * @Author: gujiangbo.co
 * @Contact: 646832012@qq.com
 * @Date: 2022/4/8 21:37
 * @Version: 1.0
 * @Description: 引用计数法测试
 * -XX:+PrintGCDetails
 */
public class JavaRefCountGC {
    // 5M 这个作用就是占用一点内存
    private byte[] bigze = new byte[5 * 1024 * 1024];
    Object reference = null;

    public static void main(String[] args) {
        JavaRefCountGC obj1 = new JavaRefCountGC();
        JavaRefCountGC obj2 = new JavaRefCountGC();

        obj1.reference = obj2;
        obj2.reference = obj1;
        // 显式的执行gc,此处如果被回收则证明JVM不是使用引用计数算法
        System.gc();

    }
}
